/*
 * GHibernateDaoSupport.java
 * Created on 25 oct. 06
 *
 * VirtualHockey.net Internet Platform
 * Copyright (c) 2005-2006, Jan Janke
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hockeo.vhbase.utils.data;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
 * Utility class that can be used as base class for Hibernate DAO implementations. This
 * class stores the Hibernate {@link SessionFactory} and provides accessors for it.
 *
 * @version $Id: GHibernateDaoSupport.java 46 2006-10-29 17:26:48Z janjanke $
 * @author jjanke
 */
public class GHibernateDaoSupport
{
  /**
   * Hibernate SessionFactory.
   */
  private SessionFactory d_sessionFactory;

  /**
   * Return the Hibernate SessionFactory used by this DAO.
   */
  public SessionFactory getSessionFactory()
  {
    return d_sessionFactory;
  }

  /**
   * Sets the Hibernate SessionFactory to be used by this DAO.
   */
  public void setSessionFactory( SessionFactory sessionFactory )
  {
    d_sessionFactory = sessionFactory;
  }

  /**
   * Returns the currently active session.
   */
  protected Session getSession()
  {
    return d_sessionFactory.getCurrentSession();
  }
}
